from fasc_api.client.billing_client import BillingClient
from fasc_api.client.service_client import ServiceClient
from fasc_api.exception.exceptions import ClientException
from fasc_api.exception.exceptions import ServerException

from init_demo_data import InitDemoData
api_client = InitDemoData.api_client
access_token = ServiceClient.get_access_token_value(api_client)
api_client.set_access_token(access_token)


# 获取计费链接
def get_bill_url_demo():
    try:
        data = {
            'openId': {
                'idType': '主体类型：corp: 企业, person: 个人',
                # 法大大平台为该企业在该应用appId范围内分配的唯一标识
                'openCorpId': InitDemoData.openCorpId,
                # （可选）个人经办人
                'openUserId': InitDemoData.openUserId
            },
            'urlType': '计费页面类型：account: 账户信息， order: 套餐订购。默认为account。',
            'redirectUrl': '返回地址'
        }
        res = BillingClient.get_bill_url(api_client, data)
        print(res)
    except ClientException as e:
        print(e.__str__())
    except ServerException as e:
        print(e.__str__())

if __name__ == '__main__':
    get_bill_url_demo()